import * as types from '../constants/ActionTypes'

const initialState = {
  isRegisting: false,
}

export default function register(state = initialState, action) {
  switch (action.type) {
    case types.REGISTING:
			return Object.assign({}, state,{
        isRegisting: true,
        uname: action.uname,
        pwd: action.pwd,
        phone: action.phone,
        errorMessage: 'OK',
      });
    case types.REGISTERSUCCESS:
      return Object.assign({}, state, {
        isRegisting: false,
        isRegisterSuccess: true,
      });
    case types.REGISTERFAIL:
      return Object.assign({}, state, {
        isRegisting: false,
        isRegisterSuccess: false,
        errorMessage: action.errorMessage,
      });  
    default:
      return state;   
  }
}